package com.wolf.etl.core.dialect;

import com.wolf.etl.model.EtlTableModel;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @author sdyang
 * @date 2019/11/5 15:39
 **/
@Service("Db2Dialect")
public class Db2Dialect extends AbstractDialect{


    @Override
    public String buildPaginationSql(String originalSql, int offset, int limit) {
        long firstParam = offset + 1;
        long secondParam = offset + limit;
        String sql = "SELECT * FROM (SELECT TMP_PAGE.*,ROWNUMBER() OVER() AS ROW_ID FROM ( %s ) AS TMP_PAGE) TMP_PAGE WHERE ROW_ID BETWEEN %s AND %s " ;
        return String.format(sql,originalSql,firstParam,secondParam);

    }

    @Override
    public String buildInsertSelect(EtlTableModel table, String targerTableName, Map<String, String> fields) {
        return null;
    }
}
